<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .tt{
            width: 300px;
            height: 500px;
            border: 1px solid red;
            /* text-align: center; */
        }
        .tt li{
            list-style: none;
            /* float: left; */
            /* width: 300px;
            height: 16px;
            background-color: red; */

            /* display: flex; */
        }
        #txt{
            text-align: center;
            
        }
        .tt img{
            display: block;
            width: 300px;
            height: 300px;
        }
        .tt em{
            display: flex;
        }

    </style>
</head>
<body>
    <div class="tt">
        <img src="./img/p1.jpg" alt="">
        <li>
            <h4>好东西</h4>
            <em> 价格:￥<span id="hh">20000</span></em>
        </li>
        数量：<input type="button" value="-" id="jian" m> 
        <input type="text" id="txt" value="0">
        <input type="button" value="+" id="jia"><br />
        总价：<span id="zz"></span>
    </div>
</body>
</html>
<script>
    jia.onclick =function(){
        txt.value++
        zz.innerHTML=hh.innerHTML*txt.value

    }
    jian.onclick =function(){
        if(txt.value>0){
            txt.value--
            zz.innerHTML=hh.innerHTML*txt.value

        }
        
    }
</script>